import {useRoutes ,Navigate} from 'react-router-dom'
import Home from '../views/Home'
import Music from '../views/Music'
import Hot from '../views/Hot'
import News from '../views/News'
import Detail from '../views/Detail'
import Todolist from '../views/Todolist'
import Header from '../views/Header'
import ErrorPage from '../views/ErrorPage'
const RouterView = () => {
    const routes = useRoutes([
      {
        path: "/home",
        element: <Home/>
      }, {
        path: "/music",
        element: <Music/>,
        children: [
          /* 路由重定向 */
          {
            path: "/music",
            element: <Navigate to="/music/news"/>
          }, {
            path: "news",
            element: <News/>
          }, {
            path: "hot",
            element: <Hot/>
          }
        ]
      },
      {
          path:"/detail/:id",
          element:<Detail/>
      },
      {
          path:'/todolist',
          element:<Todolist/>
      },{
          path:"/",
          element:<Header/>
      },{
        path:"*",
        element:<ErrorPage/>
      }
    ])
    return routes;
  }
export default  RouterView;